﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1.DesignerPatter.ChainOfRespinsibility
{
    class ConcretHandler1:Handler 
    {
        public override void HandlerRequest(int request)
        {
            if (request >= 0 && request < 10)
            {
                Console.WriteLine(string.Format("{0}处理请求{1}",this.GetType().Name,request));
            }
            else if(successor != null) 
            {
                successor.HandlerRequest(request);
            }
        }
    }

    class ConcretHandler2 : Handler
    {
        public override void HandlerRequest(int request)
        {
            if (request >= 10 && request < 20)
            {
                Console.WriteLine(string.Format("{0}处理请求{1}", this.GetType().Name, request));
            }
            else if (successor != null)
            {
                successor.HandlerRequest(request);
            }
        }
    }


    class ConcretHandler3 : Handler
    {
        public override void HandlerRequest(int request)
        {
            if (request >= 20 && request < 30)
            {
                Console.WriteLine(string.Format("{0}处理请求{1}", this.GetType().Name, request));
            }
            else if (successor != null)
            {
                successor.HandlerRequest(request);
            }
        }
    }
}
